package com.hb.unic.core.util;

import java.io.PrintWriter;
import java.io.StringWriter;

/**
 * 异常工具类
 *
 * @since v1.0，2023/8/25 22:50，create by Mr.Huang.
 */
public class ExceptionUtils {

    /**
     * 获取异常堆栈信息
     *
     * @param throwable 异常超类
     * @return 堆栈信息
     */
    public static String getStackTrace(final Throwable throwable) {
        final StringWriter sw = new StringWriter();
        final PrintWriter pw = new PrintWriter(sw, true);
        throwable.printStackTrace(pw);
        return sw.getBuffer().toString();
    }

}
